package acwing.二分;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;


/**
 * 日志统计
 *
 * @author yang
 * @date 2021/12/6
 */
public class 日志统计 {

    static int N = 100010;
    static PIIs[] logs = new PIIs[N];
    static int[] cut = new int[N];
    static boolean[] st = new boolean[N];

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = reader.readLine().split(" ");
        int n = Integer.parseInt(s1[0]);
        int d = Integer.parseInt(s1[1]);
        int k = Integer.parseInt(s1[2]);
        // 初始化
        for (int i = 0; i < n; i++) {
            String[] s2 = reader.readLine().split(" ");
            int t = Integer.parseInt(s2[0]);
            int id = Integer.parseInt(s2[1]);
            logs[i] = new PIIs(t, id);
        }
        Arrays.sort(logs,0, n);
        // lc.双指针
        for (int i = 0, j = 0; i < n; i++) {
            int id = logs[i].id;
            cut[id]++;
            // 超出时间
            while (logs[i].t - logs[j].t >= d) {
                cut[logs[j].id]--;
                j++;
            }
            // 标记结果
            if (cut[id] >= k) st[id] = true;
        }
        for (int i = 0; i <= 100000; i++) {
            if(st[i]) System.out.println(i);
        }
    }



}
class PIIs implements Comparable<PIIs> {

    public int t;
    public int id;

    public PIIs(int t, int id) {
        this.t = t;
        this.id = id;
    }

    @Override
    public int compareTo(PIIs o) {
        // 通过时间来排序
        return Integer.compare(t,o.t);
    }
}